package jblip.resources;

import java.io.Serializable;

/**
 * <i>User</i> resource interface.
 * 
 * <p>
 * <i>User</i> describes a user of system, with personalization data, such as
 * background image or profile picture.
 * </p>
 * 
 * @author Krzysztof Sroka
 * @since 0.1
 */
public interface User extends Serializable {
  public static enum Sex {
    MALE {
      @Override
      public String toString() {
        return "m";
      }
    },

    FEMALE {
      @Override
      public String toString() {
        return "f";
      }
    },

    UNKNOWN {
      @Override
      public String toString() {
        return "?";
      }
    };

    public static Sex fromString(String string) {
      if (string.length() == 0) {
        return null;
      }
      switch (string.charAt(0)) {
        case 'm' : return MALE;
        case 'f' : return FEMALE;
        default : return UNKNOWN; 
      }
    }

  }

  /**
   * Gets user's ID.
   * 
   * @return ID of this resource.
   */
  Integer getID();

  /**
   * Gets user's login name;
   * 
   * @return Login name of this resource.
   */
  String getLogin();

  /**
   * Gets user's profile picture ("avatar").
   * 
   * @return <i>Picture</i> resource attached as this user's picture, or
   *         <code>null</code> if it isn't set.
   */
  UserPicture getAvatar();

  /**
   * Gets path for user's profile picture.
   * 
   * <p>
   * Not null avatar path indicates that there is a profile picture associated
   * with this user, but wasn't fetched as a Media resource.
   * </p>
   * 
   * @return String indicating path to this user's profile picture on blip
   *         server, or <code>null</code> if the picture is available through
   *         {@link #getAvatar()} or if it's not available at all.
   * 
   * @see #getAvatar()
   */
  String getAvatarPath();

  /**
   * Gets user's background picture.
   * 
   * @return <i>Picture</i> resource attached as this user's background, or
   *         <code>null</code> if it isn't set.
   */
  Media getBackground();

  /**
   * Gets path for user's profile picture.
   * 
   * <p>
   * Not null background path indicates that there is a background picture
   * associated with this user, but wasn't fetched as a Media resource.
   * </p>
   * 
   * @return String indicating path to this user's background picture on blip
   *         server, or <code>null</code> if the picture is available through
   *         {@link #getBackground()} or if it's not available at all.
   * 
   * @see #getBackground()
   */
  String getBackgroundPath();

  /**
   * Gets user's current status.
   * 
   * @return <i>Update</i> resource attached to this user as the last status
   *         message set by him/her, or <code>null</code> if it isn't set.
   */
  Update getCurrentStatus();

  /**
   * Gets users location.
   * 
   * @return User-provided string describing his/hers location, or
   *         <code>null</code> if it isn't present
   */
  String getLocation();

  /**
   * Gets user sex.
   * 
   * @return User-provided data on his/hers sex.
   */
  Sex getSex();
}
